import request from '../request.js'

export const login = (loginForm) => {
  return request.post(`login?username=${ loginForm.username }&password=${ loginForm.password }&remember-me=${ loginForm.rememberpwd }`, {withCredentials: true})
}

export const logout = () => {
  return request.post('logout')
}

export const getUsersByGroupIdApi = (groupId, pageNum, pageSize) => {
  return request.get(`personnel/user/memeber/group?groupId=${ groupId }&pageNum=${ pageNum }&pageSize=${ pageSize }`)
}

export const getUsersByGroupIdAndStationIdApi = (groupId, stationId, pageNum, pageSize) => {
  return request.get(`personnel/user/memeber/group?groupId=${ groupId }&stationId=${ stationId }&pageNum=${ pageNum }&pageSize=${ pageSize }`)
}

export const getUserAuthoritiesApi = () => {
  return request.post('index/get/system/current')
}

export const getSystemAuthoritiesApi = () => {
  return request.post('index/get/system/all')
}

export const postAddMemberApi = (data) => {
  return request.post('personnel/user/memeber/add', data)
}

export const postUpdateMemberApi = (data) => {
  return request.post('personnel/user/memeber/update', data)
}

export const postRemoveMemberByUsernameApi = (data) => {
  return request.post('personnel/user/memeber/remove', data)
}


//修改密码
export const putUpdatePassword = (data) => {
  return request.put('personal/user/updatePassword', data)
}

//发送邮箱验证
export const PostSendEmailCode = (data) => {
  return request.post('personal/user/sendEmailCode', {
    username: data.username,
    email: data.email,
    timeStamp: Date.now(),
  })
}

//绑定验证码
export const PostBindEmail = (data) => {
  return request.post('personal/user/bindEmail', data)
}

//解绑验证码
export const PostUnBindEmail = (data) => {
  return request.post(`personal/user/unbindEmail?username=${ data.username }`)
}
